/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aiaudio.database.tables;

import aiaudio.database.Family;
import java.util.NavigableMap;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

/**
 *
 * @author nastya
 */
public class NeighbourGroupToUserTable extends TableStructure {

    private final static Family GROUPS = new Family("g");
    private final static Family USERS = new Family("u");
    private final static Family DATA = new Family("d");

    public static void addUserToGroup(Put put, byte[] userName, double distance) {
        put.add(USERS.getNameAsBytes(), userName, Bytes.toBytes(distance));
    }

    public static NavigableMap<byte[], byte[]> getUsers(Result r) {
        return r.getFamilyMap(USERS.getNameAsBytes());
    }

    @Override
    public Family[] getAllFamilies() {
        return new Family[]{GROUPS, USERS, DATA};
    }
}
